//Sample using LiquidCrystal library
#include <LiquidCrystal.h>

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int echoPin = 2;  // digital pin to receive echo pulse
int triggerPin = 3;  // digital pin to send trigger pulse
double distance = 0, inches = 0;
int no_decimal = 0;

String stringdistance = 0;


void setup() {
	lcd.begin(16, 2);              // start the library
	pinMode(echoPin, INPUT);
	pinMode(triggerPin, OUTPUT);
}

void loop() {
	digitalWrite(triggerPin, HIGH); // set HIGH for 15us to trigger ranging
	delayMicroseconds(15);
	digitalWrite(triggerPin, LOW);  // set pin LOW
	distance = pulseIn(echoPin, HIGH);  // read in pulse length
	distance = distance / 120.0; // calculate distance from pulse length
	no_decimal = distance;
	inches = (distance - no_decimal)*12.0;
//	lcd.clear();
	lcd.setCursor(5,0);  
	if (distance > 12) {
		lcd.print("ft: ");
		lcd.print(distance,1);
		lcd.setCursor(5,1);
		lcd.print("inches: ");
		lcd.print(inches,1);

//		stringdistance = distance + " ft";
//		lcd.setCursor(5,0);  
//		lcd.println("test" + distance);
	}
	delay(50);  // wait 50ms for next ranging

	
	//lcd.println("test");
	//if (distance > 12) {
		//stringdistance = distance + " ft";
		
//		lcd.println(distance);
		//}
}
